If a package contains a subdirectory that contains a copy of
itself (strange, but encountered in the wild in the context of an OS
package build tool), cargo was failing with a non-descriptive "An
unknown error occurred" (or "no package found in source" with
--verbose).
Since nested packages use the root path, such a package will have an
identical package_id to the root package. With this patch, we keep the
first occurance of a given package_id rather than overwritting --
effectively ignoring the nested package with duplicated name. A warn!
message is printed.
let manifest = try!(find_project_manifest_exact(path, "Cargo.toml"));
let (pkg, nested) = try!(read_package(&manifest, source_id, config));
- all_packages.insert(pkg.package_id().clone(), pkg);
+ let pkg_id = pkg.package_id().clone();
+ if !all_packages.contains_key(&pkg_id) {
+ all_packages.insert(pkg_id, pkg);
+ } else {
+ warn!("skipping nested package `{}` found at `{}`",
+ &pkg.name(), &path.to_string_lossy());
+ }
// Registry sources are not allowed to have `path=` dependencies because
// they're all translated to actual registry dependencies.